package cn.iocoder.yudao.module.handguard.dal.mysql.wealthrecord;

import java.math.BigDecimal;
import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.handguard.dal.dataobject.wealthrecord.WealthRecordDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.handguard.controller.app.wealthrecord.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 用户-财富值明细记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface WealthRecordMapper extends BaseMapperX<WealthRecordDO> {

    default PageResult<WealthRecordDO> selectPage(WealthRecordPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<WealthRecordDO>()
                .eqIfPresent(WealthRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(WealthRecordDO::getWealthValue, reqVO.getWealthValue())
                .eqIfPresent(WealthRecordDO::getIOrDecrease, reqVO.getIOrDecrease())
                .eqIfPresent(WealthRecordDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(WealthRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WealthRecordDO::getId));
    }

    default List<WealthRecordDO> selectList(WealthRecordExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<WealthRecordDO>()
                .eqIfPresent(WealthRecordDO::getUserId, reqVO.getUserId())
                .eqIfPresent(WealthRecordDO::getWealthValue, reqVO.getWealthValue())
                .eqIfPresent(WealthRecordDO::getIOrDecrease, reqVO.getIOrDecrease())
                .eqIfPresent(WealthRecordDO::getRemark, reqVO.getRemark())
                .betweenIfPresent(WealthRecordDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(WealthRecordDO::getId));
    }

    Long findByPageCount(WealthRecordPageReqsVO pageVO);

    List<UserWealthRecordRespVO> findByPage(WealthRecordPageReqsVO pageVO);

    WealthRespVO getWealthByUserId(Long userId);


    void updateMyWealth(@Param("userId") Long userId, @Param("wealth") BigDecimal wealth);

    void updateRate(@Param("rateValue")BigDecimal rateValue,@Param("key")String key);
}
